package com.wn.icloud.common.utils;

import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @author star
 * @date 2019/4/19
 **/
public class ConvertUtil {

    /**
     * 分割符
     */
    public static String SPLIT = "_";

    /**
     * ids转化为Long 集合
     *
     * @param ids
     * @return
     */
    public static List<Long> Ids2LongList(String ids) {
        return Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList());
    }


    /**
     * ids转化为String 集合
     *
     * @param ids
     * @return
     */
    public static List<String> Ids2StringList(String ids) {
        return Arrays.stream(ids.split(",")).map(String::valueOf).collect(Collectors.toList());
    }

    /**
     * Long集合转化为以逗号分隔的字符串
     * @param ids
     * @return
     */
    public static String list2String(List<Long> ids){
        return ids.stream().map(id->String.valueOf(id)).collect(Collectors.joining(","));
    }

    /**
     * String集合转化为以Long集合
     * @param ids
     * @return
     */
    public static List<Long> stringList2LongList(List<String> ids){
        return ids.stream().map(id->Long.valueOf(id)).collect(Collectors.toList());
    }

    /**
     * Long集合转化为以String集合
     * @param ids
     * @return
     */
    public static List<String> longList2StringList(Set<Long> ids){
        return ids.stream().map(id->String.valueOf(id)).collect(Collectors.toList());
    }
}
